/*
 * $Id: GeodataDTModelResponseBuilder.java 42 2013-04-17 15:33:59Z gabakyan $
 * $Author: gabakyan $
 * $Revision: 42 $
 * $Date: 2013-04-17 15:33:59 +0000 (Wed, 17 Apr 2013) $
 *
 * Copyright (c) 2013 Supply Chain Intelligence (SCI), Inc.
 * http://www.scintelligence.com/, Email: info@scintelligence.com
 * All rights reserved.
 *
 * This file is part of Logistics Map.
 *
 * Logistics Map is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * Logistics Map is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Logistics Map.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.sci.logisticsmap.service.support.builder.response;

import com.sci.logisticsmap.data.model.GeodataModel;
import com.sci.logisticsmap.data.model.LocationModel;
import com.sci.logisticsmap.support.converter.ConversionUtilities;
import com.sci.logisticsmap.service.model.GeodataDTModel;
import com.sci.logisticsmap.service.model.LocationLightDTModel;

import java.util.List;

/**
 * The class {@code GeodataDTModelResponseBuilder} represents the {@link GeodataDTModel} response builder.
 *
 * @author gabakyan@gmail.com (Last modified by $Author: gabakyan $)
 * @version $Revision: 42 $
 */
public class GeodataDTModelResponseBuilder extends BaseResponseBuilder<GeodataDTModel> {
    /**
     * The Geodata.
     */
    private GeodataModel geodata;
//    /**
//     * The Geodata Locations.
//     */
//    private GeodataLocationsModel geodataLocations;
    /**
     * The locations.
     */
    private List<? extends LocationModel> locations;

    /**
     * The conversion utilities.
     */
    private ConversionUtilities conversionUtilities;

    /**
     * Constructs a new {@link GeodataDTModel} response builder.
     *
     * @param conversionUtilities The conversion utilities.
     */
    public GeodataDTModelResponseBuilder(ConversionUtilities conversionUtilities) {
        this.conversionUtilities = conversionUtilities;
    }

    /*
     * (non-Javadoc)
     *
     * @see com.sci.logisticsmap.service.support.builder.response.BaseResponseBuilder#build()
     */
    @Override
    public GeodataDTModel build() {
        GeodataDTModel response = null;
        if (geodata != null) {
            response = conversionUtilities.convert(geodata, GeodataDTModel.class);
            /*if (geodataLocations != null) {
                response.setLocations(conversionUtilities.convert(geodataLocations.getLocations(), LocationLightDTModel.class));
                geodataLocations = null;
            }*/
            if (locations != null) {
                response.setLocations(conversionUtilities.convert(locations, LocationLightDTModel.class));
                locations = null;
            }
            geodata = null;
        }
        return response;
    }

    /**
     * Sets the Geodata.
     *
     * @param geodata The Geodata.
     *
     * @return The reference to the {@link GeodataDTModel} builder.
     */
    public GeodataDTModelResponseBuilder setGeodata(GeodataModel geodata) {
        this.geodata = geodata;
        return this;
    }

//    /**
//     * Sets the Geodata Locations.
//     *
//     * @param geodataLocations The Geodata Locations.
//     *
//     * @return The reference to the {@link GeodataDTModel} builder.
//     */
//    public GeodataBeanResponseBuilder setGeodataLocations(GeodataLocationsModel geodataLocations) {
//        this.geodataLocations = geodataLocations;
//        return this;
//    }

    /**
     * Sets the Locations.
     *
     * @param locations The Locations.
     *
     * @return The reference to the {@link GeodataDTModel} builder.
     */
    public GeodataDTModelResponseBuilder setLocations(List<? extends LocationModel> locations) {
        this.locations = locations;
        return this;
    }
}
